package cn.wolfcode.luowowo.website.advice;

import cn.wolfcoe.luowowo.common.exception.LogicException;
import cn.wolfcoe.luowowo.common.util.AjaxResult;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class CommonExceptionHandler {

    @ExceptionHandler(LogicException.class)
    @ResponseBody
    private Object handleLogicException(Exception e) {
        return new AjaxResult( false, e.getMessage() );
    }

    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    private Object handleRuntimeException(Exception e) {

        e.printStackTrace();
        return new AjaxResult( false, "系统繁忙,请稍后再试!" );
    }
}
